#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "renderer.h"
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->actionView->setChecked(true);
    connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(set_text_lambda(int)));
    connect(ui->horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(set_text_tropism(int)));
    connect(ui->horizontalSlider_3, SIGNAL(valueChanged(int)), this, SLOT(set_text_aux_angle(int)));
    connect(ui->horizontalSlider_4, SIGNAL(valueChanged(int)), this, SLOT(set_text_shed_thres(int)));
    connect(ui->horizontalSlider_5, SIGNAL(valueChanged(int)), this, SLOT(set_text_term_weight(int)));
    connect(ui->horizontalSlider_6, SIGNAL(valueChanged(int)), this, SLOT(set_text_aux_weight(int)));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::set_text_lambda(int val){
    float scaled_val = val;
    ui->label_8->setText(QString::number(3.2456456,'g', 3));
}

void MainWindow::set_text_tropism(int val){
        float scaled_val = val;
    ui->label_9->setText(QString::number(scaled_val,'g', 3));
}
void MainWindow::set_text_aux_angle(int val){
            float scaled_val = val;
    ui->label_10->setText(QString::number(scaled_val,'g', 3));
}
void MainWindow::set_text_shed_thres(int val){
            float scaled_val = val;
    ui->label_11->setText(QString::number(scaled_val,'g', 3));
}
void MainWindow::set_text_term_weight(int val){
            float scaled_val = val;
    ui->label_12->setText(QString::number(scaled_val,'g', 3));
}
void MainWindow::set_text_aux_weight(int val){
            float scaled_val = val;
    ui->label_13->setText(QString::number(scaled_val,'g', 3));
}

void MainWindow::on_actionView_triggered(bool checked)
{
}

void MainWindow::on_actionDraw_triggered(bool checked)
{
}

void MainWindow::on_actionView_triggered(){
    ui->actionView->setChecked(true);
    ui->actionDraw->setChecked(false);
    ui->widget->modeInteract = false;
    ui->widget_2->modeInteract = false;
}
void MainWindow::on_actionDraw_triggered(){
    ui->actionView->setChecked(false);
    ui->actionDraw->setChecked(true);
    ui->widget->modeInteract = true;
    ui->widget_2->modeInteract = true;
}

void MainWindow::on_actionQuit_triggered()
{
    exit(0);
}


void MainWindow::on_pushButton_clicked()
{
    ui->widget->applyValues();
    ui->widget_2->applyValues();
}

void MainWindow::on_pushButton_2_clicked()
{

}

void MainWindow::on_pushButton_3_clicked()
{

}

void MainWindow::on_horizontalSlider_valueChanged(int value)
{
    //VALUES RANGE FROM 0 to 99
    ui->widget->lambda = value;
    ui->widget_2->lambda = value;
}

void MainWindow::on_horizontalSlider_2_valueChanged(int value)
{
    ui->widget->tropism = value;
    ui->widget_2->tropism = value;
}

void MainWindow::on_horizontalSlider_3_valueChanged(int value)
{
    ui->widget->aux_angle = value;
    ui->widget_2->aux_angle = value;
}

void MainWindow::on_horizontalSlider_4_valueChanged(int value)
{
    ui->widget->shed_thres = value;
    ui->widget_2->shed_thres = value;
}

void MainWindow::on_horizontalSlider_5_valueChanged(int value)
{
    ui->widget->term_weight = value;
    ui->widget_2->term_weight = value;
}

void MainWindow::on_horizontalSlider_6_valueChanged(int value)
{
    ui->widget->aux_weight = value;
    ui->widget_2->aux_weight = value;
}


